var co = {};
function recalc_onclick() {
	if (true) {
		co.XLEW_1_5_9 = eeparsedate_keep_allV(document.formc.XLEW_1_5_9.value);
		co.XLEW_1_8_4 = eeparsedate_keep_allV(document.formc.XLEW_1_8_4.value);
		co.XLEW_1_12_4 = eeparsedate_keep_allV(document.formc.XLEW_1_12_4.value);
		co.XLEW_1_12_9 = eeparseFloatTh(document.formc.XLEW_1_12_9.value);
		co.XLEW_1_12_12 = eeparseFloatTh(document.formc.XLEW_1_12_12.value);
		co.XLEW_1_13_4 = eeparsedate_keep_allV(document.formc.XLEW_1_13_4.value);
		co.XLEW_1_13_9 = eeparseFloatTh(document.formc.XLEW_1_13_9.value);
		co.XLEW_1_13_12 = eeparseFloatTh(document.formc.XLEW_1_13_12.value);
		co.XLEW_1_14_4 = eeparsedate_keep_allV(document.formc.XLEW_1_14_4.value);
		co.XLEW_1_14_9 = eeparseFloatTh(document.formc.XLEW_1_14_9.value);
		co.XLEW_1_14_12 = eeparseFloatTh(document.formc.XLEW_1_14_12.value);
		co.XLEW_1_16_2 = document.formc.XLEW_1_16_2.value;
		co.XLEW_1_16_4 = eeparsedate_keep_allV(document.formc.XLEW_1_16_4.value);
		co.XLEW_1_16_9 = eeparseFloatTh(document.formc.XLEW_1_16_9.value);
		co.XLEW_1_16_12 = eeparseFloatTh(document.formc.XLEW_1_16_12.value);
		co.XLEW_1_17_2 = document.formc.XLEW_1_17_2.value;
		co.XLEW_1_17_4 = eeparsedate_keep_allV(document.formc.XLEW_1_17_4.value);
		co.XLEW_1_17_9 = eeparseFloatTh(document.formc.XLEW_1_17_9.value);
		co.XLEW_1_17_12 = eeparseFloatTh(document.formc.XLEW_1_17_12.value);
		co.XLEW_1_18_2 = document.formc.XLEW_1_18_2.value;
		co.XLEW_1_18_4 = eeparsedate_keep_allV(document.formc.XLEW_1_18_4.value);
		co.XLEW_1_18_9 = eeparseFloatTh(document.formc.XLEW_1_18_9.value);
		co.XLEW_1_18_12 = eeparseFloatTh(document.formc.XLEW_1_18_12.value);
		co.XLEW_1_20_9 = eeparseFloatTh(document.formc.XLEW_1_20_9.value);
		co.XLEW_1_23_4 = eeparsedate_keep_allV(document.formc.XLEW_1_23_4.value);
		co.XLEW_1_23_12 = eeparseFloatTh(document.formc.XLEW_1_23_12.value);
		co.XLEW_1_24_4 = eeparsedate_keep_allV(document.formc.XLEW_1_24_4.value);
		co.XLEW_1_24_12 = eeparseFloatTh(document.formc.XLEW_1_24_12.value);
		co.XLEW_1_25_4 = eeparsedate_keep_allV(document.formc.XLEW_1_25_4.value);
		co.XLEW_1_25_12 = eeparseFloatTh(document.formc.XLEW_1_25_12.value);
		co.XLEW_1_27_4 = eeparsedate_keep_allV(document.formc.XLEW_1_27_4.value);
		co.XLEW_1_27_12 = eeparseFloatTh(document.formc.XLEW_1_27_12.value);
		co.XLEW_1_29_4 = eeparsedate_keep_allV(document.formc.XLEW_1_29_4.value);
		co.XLEW_1_29_12 = eeparseFloatTh(document.formc.XLEW_1_29_12.value);
		co.XLEW_1_31_9 = eeparseFloatTh(document.formc.XLEW_1_31_9.value);
		co.XLEW_1_32_4 = eeparsedate_keep_allV(document.formc.XLEW_1_32_4.value);
		co.XLEW_1_33_4 = eeparsedate_keep_allV(document.formc.XLEW_1_33_4.value);
		co.XLEW_1_34_4 = eeparsedate_keep_allV(document.formc.XLEW_1_34_4.value);
		co.XLEW_1_34_12 = eeparseFloatTh(document.formc.XLEW_1_34_12.value);
		co.XLEW_1_35_4 = eeparsedate_keep_allV(document.formc.XLEW_1_35_4.value);
		co.XLEW_1_35_12 = eeparseFloatTh(document.formc.XLEW_1_35_12.value);
		co.XLEW_1_36_4 = eeparsedate_keep_allV(document.formc.XLEW_1_36_4.value);
		co.XLEW_1_36_12 = eeparseFloatTh(document.formc.XLEW_1_36_12.value);
		co.XLEW_1_38_4 = eeparsedate_keep_allV(document.formc.XLEW_1_38_4.value);
		co.XLEW_1_38_12 = eeparseFloatTh(document.formc.XLEW_1_38_12.value);
		co.XLEW_1_39_4 = eeparsedate_keep_allV(document.formc.XLEW_1_39_4.value);
		co.XLEW_1_39_12 = eeparseFloatTh(document.formc.XLEW_1_39_12.value);
		co.XLEW_1_40_4 = eeparsedate_keep_allV(document.formc.XLEW_1_40_4.value);
		co.XLEW_1_40_12 = eeparseFloatTh(document.formc.XLEW_1_40_12.value);
		co.XLEW_1_42_2 = document.formc.XLEW_1_42_2.value;
		co.XLEW_1_42_4 = eeparsedate_keep_allV(document.formc.XLEW_1_42_4.value);
		co.XLEW_1_42_12 = eeparseFloatTh(document.formc.XLEW_1_42_12.value);
		co.XLEW_1_43_2 = document.formc.XLEW_1_43_2.value;
		co.XLEW_1_43_4 = eeparsedate_keep_allV(document.formc.XLEW_1_43_4.value);
		co.XLEW_1_43_12 = eeparseFloatTh(document.formc.XLEW_1_43_12.value);
		co.XLEW_1_44_2 = document.formc.XLEW_1_44_2.value;
		co.XLEW_1_44_4 = eeparsedate_keep_allV(document.formc.XLEW_1_44_4.value);
		co.XLEW_1_44_12 = eeparseFloatTh(document.formc.XLEW_1_44_12.value);
		var op=top.frames["main"].document.getElementById('pollOpen');if(op.value!=''){op.value='true';}else{op.value='false';}calc(co);
		document.formc.XLEW_1_10_9.value = eedisplayFloatNDTh(co.XLEW_1_10_9, 0);
		document.formc.XLEW_1_10_12.value = eedisplayFloatNDTh(co.XLEW_1_10_12,
				0);
		document.formc.XLEW_1_10_15.value = eedisplayFloatNDTh(co.XLEW_1_10_15,
				0);
		document.formc.XLEW_1_12_15.value = eedisplayFloatNDTh(co.XLEW_1_12_15,
				0);
		document.formc.XLEW_1_13_15.value = eedisplayFloatNDTh(co.XLEW_1_13_15,
				0);
		document.formc.XLEW_1_14_15.value = eedisplayFloatNDTh(co.XLEW_1_14_15,
				0);
		document.formc.XLEW_1_15_9.value = eedisplayFloatNDTh(co.XLEW_1_15_9, 0);
		document.formc.XLEW_1_15_12.value = eedisplayFloatNDTh(co.XLEW_1_15_12,
				0);
		document.formc.XLEW_1_15_15.value = eedisplayFloatNDTh(co.XLEW_1_15_15,
				0);
		document.formc.XLEW_1_16_15.value = eedisplayFloatNDTh(co.XLEW_1_16_15,
				0);
		document.formc.XLEW_1_17_15.value = eedisplayFloatNDTh(co.XLEW_1_17_15,
				0);
		document.formc.XLEW_1_18_15.value = eedisplayFloatNDTh(co.XLEW_1_18_15,
				0);
		document.formc.XLEW_1_20_12.value = eedisplayFloatNDTh(co.XLEW_1_20_12,
				0);
		document.formc.XLEW_1_20_15.value = eedisplayFloatNDTh(co.XLEW_1_20_15,
				0);
		document.formc.XLEW_1_22_12.value = eedisplayFloatNDTh(co.XLEW_1_22_12,
				0);
		document.formc.XLEW_1_31_12.value = eedisplayFloatNDTh(co.XLEW_1_31_12,
				0);
		document.formc.XLEW_1_31_15.value = eedisplayFloatNDTh(co.XLEW_1_31_15,
				0);
		document.formc.XLEW_1_33_12.value = eedisplayFloatNDTh(co.XLEW_1_33_12,
				0);
		document.formc.XLEW_1_41_12.value = eedisplayFloatNDTh(co.XLEW_1_41_12,
				0);
		document.formc.XLEW_1_46_9.value = eedisplayFloatNDTh(co.XLEW_1_46_9, 0);
		document.formc.XLEW_1_46_15.value = eedisplayFloatNDTh(co.XLEW_1_46_15,
				0);
		
		controlDates();
	}
}
		
//	function checkValues()
//	{
//		if (!controlDates2())
//		{
//			alert("Complete correctamente todas las fechas de asamblea.");
//		}
//		else
//		{
//			getxmlHttpRequest('savePoll', 'formc', 'message', 'wait');
//		}
//	}
//
//	function controlDates2()
//	{	
//		var classElems = getElementsByClassName('controlDate',null);
//		var i = 0;
//		while(i < classElems.length)
//		{
//			var value = classElems[i].value;
//			if(!(value != null && value.trim().length > 0))
//			{
//				return false;
//				break;
//			}
//			i++;
//		}
//		return true;
//	}

	function controlDates()
	{		
		var date = eeparsedate_keep_allV(document.formc.XLEW_1_5_9.value);
		
		if(controlValidDate(date))
		{
			if(controlDateIsMinorCampaign(date))
			{
				var classElems = getElementsByClassName('controlDate',null);
				var i = 0;
				while(i < classElems.length)
				{
					var value = classElems[i].value;
					if(value != null && value.trim().length > 0)
					{
						if(!controlValidDate(value))
						{
							alert("La fecha ingresada '" + value + "' no es válida.");
							classElems[i].value = "";
						}
						else
						{
							if((!controlDateIsMinor(value,date)) || (!controlDateIsMayor(value,datePreviousYear(date))))
							{
								alert("La fecha ingresada '" + value + "' debe ser hasta un año menor que la fecha de cierre de los estados contables.");
								classElems[i].value = "";
							}
						}
					}
					i++;
				}
			}
			else
			{
				alert("La fecha ingresada '" + date + "' puede ser hasta un año mayor al año de campaña("+ document.getElementById("campaignYear").value + ").");
				document.formc.XLEW_1_5_9.value = "";
			}			
		}
		else
		{
			alert("La fecha ingresada '" + date + "' no es válida.");
			document.formc.XLEW_1_5_9.value = "";
		}		
	}

	function controlValidDate(date)
	{
		var charDet = "/";
		var splitValues = date.split(charDet);
		
		if(!splitValues.length == 3)
		{
			return false;
		}
		if(splitValues[0] == null || splitValues[0].length < 0 || splitValues[0].length >2 ||
		splitValues[1] == null || splitValues[1].length < 0 || splitValues[1].length  >2 ||
		splitValues[2] == null || splitValues[2].length < 0 || splitValues[2].length > 4)
		{
			return false;
		}
		if(isNaN(splitValues[0]) || isNaN(splitValues[1]) || isNaN(splitValues[2]))
		{
			return false;
		}	
		var day=0,month=0;
		
		day = parseInt(splitValues[0]);
		month = parseInt(splitValues[1]);
//		year = parseInt(splitValues[2]);
		
		if((day > 0) && (month > 0) && (month < 13))
		{
			if((month==1) || (month==3) || (month==5) || (month==7) || (month==8) || (month==10) || (month==12))
			{
				if(day > 31)
				{
					return false;
				}
			}
			else if(month==2)
			{
				if(day > 29)
				{
					return false;
				}
			}
			else if((month==4) || (month==6) || (month==9) || (month==11))
			{
				if(day > 30)
				{
					return false;
				}
			}
			else
			{
				return false;
			}
		}
		else
		{
			return false;
		}		
		return true;
	}
		
	
	function controlDateIsMinorCampaign(date)
	{
		var charDet = "/";
		var splitValues = date.split(charDet);
		
		var year=0;
		var campaignYear = parseInt(document.getElementById("campaignYear").value);
		year = parseInt(splitValues[2]);
		
		if((year == campaignYear) || (year  == (campaignYear + 1)))
		{
			return true;
		}
		else
		{
			return false;	
		}		
	}
	
	function datePreviousYear(date)
	{
		var charDet = "/";
		var splitValues = date.split(charDet);
		
		var day=0,month=0,year=0;
		
		day = parseInt(splitValues[0]);
		month = parseInt(splitValues[1]);
		year = parseInt(splitValues[2]) - 1;
		
		var returnDate = day.toString() + "/" + month.toString() + "/" + year.toString();
		return returnDate;
	}
	
	function controlDateIsMinor(date1,date2)
	{		
		var charDet = "/";
		var splitValues = date1.split(charDet);
		
		var day=0,month=0,year=0;
		
		day = parseInt(splitValues[0]);
		month = parseInt(splitValues[1]);
		year = parseInt(splitValues[2]);
	
		var splitValues2 = date2.split(charDet);
		
		var day2=0,month2=0,year2=0;
		
		day2 = parseInt(splitValues2[0]);
		month2 = parseInt(splitValues2[1]);
		year2 = parseInt(splitValues2[2]);
		
		if(year < year2)
		{
			return true;
		}
		else if(year == year2)
		{
			if(month < month2)
			{
				return true;
			}
			if(month == month2)
			{
				if(day <= day2)
				{
					return true;
				}
			}
		}
		return false;
	}
	
	function controlDateIsMayor(date1,date2)
	{
		var charDet = "/";
		var splitValues = date1.split(charDet);
		
		var day=0,month=0,year=0;
		
		day = parseInt(splitValues[0]);
		month = parseInt(splitValues[1]);
		year = parseInt(splitValues[2]);
	
		var splitValues2 = date2.split(charDet);
		
		var day2=0,month2=0,year2=0;
		
		day2 = parseInt(splitValues2[0]);
		month2 = parseInt(splitValues2[1]);
		year2 = parseInt(splitValues2[2]);
		
		if(year > year2)
		{
			return true;
		}
		else if(year == year2)
		{
			if(month > month2)
			{
				return true;
			}
			if(month == month2)
			{
				if(day >= day2)
				{
					return true;
				}
			}
		}
		return false;
	}
	